package com.boot.entity;

/**
 * @ClassName : tt
 * @Description : tt
 * @Author : Xxxxx
 * @Date: 2023-02-11 12:39
 */
public class tt{
    Integer g =0;

    public void add(){
//        synchronized () 锁的是对象
        synchronized (this){
            g++;
        }
    }
    public void dec(){
        synchronized (this){
            g--;
        }
    }

    public void addclass(){
        synchronized (tt.class){
            g++;
        }
    }
    public void decclass(){
        synchronized (tt.class){
            g--;
        }
    }
    @Override
    public String toString() {
        return g+"";
    }
}